|
|
|
|
|
|
|
If you have problems with the control, you can use the same debugging techniques to find the problems in a control as you do to find problems in standard programs. You can set breakpoints and step through the code line by line, whether in the ActiveX Control project or in the Standard EXE project. (See Chapter 10, ''Controlling the Flow of Your Program Code," for more information on debugging your code.) |
|
|
|
|
|
|
|
|
See "Debugging Your Programs," p. 214 |
|
|
|
|
|
|
|
|
You may have noticed by now that all the custom controls you create have the same symbol in the Toolbox. This feature can cause a lot of confusion if you are working with multiple controls. Although the ToolTips provide descriptions of the controls, having custom icons to identify each control is better. You can have this custom icon by setting the value of the ToolboxBitmap property of the user control. This property determines what is displayed in the Toolbox for your control. If the property is set to None, the default icon is used. You can set the property to any bitmap, but be aware that the Toolbox icon is only 16×15 pixels. Therefore, you should use custom bitmaps that are created in that size. |
|
|
|
|
| |
|
|
|
|
Many free icons and other graphics are available for download from the World Wide Web. For example, visit www.yahoo.com and search for "icons" to find a large list of sites. |
|
|
|
|
|
|
|
|
|
|
Using the ActiveX Control Interface Wizard |
|
|
|
|
|
|
|
|
When you created the CharAccept property of the enhanced text box, you created one piece of the public interface of the control. However, your users will probably also want to be able to access most of the standard properties, methods, and events of the text box. For example, you may have noticed that the Text property was not accessible for your custom control. This makes sense because no code was added for it; the TextBox control itself is merely an internal element of your own control. Previously, you created the CharAccept property by hand. However, as you can imagine, manually creating the dozens of properties of a control could get very tedious. |
|
|
|
|
|
|
|
|
Fortunately, Visual Basic provides a tool to make this process much easier: the ActiveX Control Interface Wizard. First, you tell the wizard the names of all the properties that you want to have for your control. The wizard then allows you to "bind" the properties of your control to the properties of a component of your control. In other words, it can write the procedure and event code for you to make the Text property of your UserControl update the Text property of the TextBox. |
|
|
|
|
|
|
|
|
Adding the Wizard to Visual Basic |
|
|
|
|
|
|
|
|
To use the ActiveX Control Interface Wizard, you first add it to your design environment. For this purpose, Visual Basic includes the Add-In Manager. To start the Add-In Manager, choose Add-Ins, Add-In Manager to open the Add-In Manager dialog box. |
|
|
|
|
|